<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Subscription Data</title>
</head>
<body>
	<ui:composition>
		<h:panelGrid columns="3">
			<h:outputLabel value="#{msg.libraryLocation}" for="libraryLocation" rendered="#{userBean.admin}" />
			<h:selectOneMenu id="libraryLocation" value="#{subscriptionBean.currentSubscription.location}" onchange="this.form.submit()" immediate="true" rendered="#{userBean.admin}">
				<f:selectItem noSelectionOption="true" itemLabel="#{msg.subscription_data_libraryLocation_noselection}" />
				<f:selectItems value="#{commonBean.libraryLocations}" var="libraryLocation" itemLabel="#{libraryLocation.city.name}" itemValue="#{libraryLocation}" />
				<f:converter converterId="libraryLocationConverter" />
				<f:valueChangeListener type="presentation.util.SubscriptionValueChangeListener" />
			</h:selectOneMenu>
			<h:message for="libraryLocation" label="#{msg.libraryLocation}" />
			
			<h:outputLabel value="#{msg.subscription_data_periodical}" for="periodical" />
			<h:selectOneMenu id="periodical" value="#{subscriptionBean.currentSubscription.periodical}">			
				<f:selectItem noSelectionOption="true" itemLabel="#{msg.subscription_data_periodical_noselection}" />
				<f:selectItems value="#{subscriptionBean.allPeriodicals}" var="periodical" itemLabel="#{periodical.title} (#{periodical.publisher})" itemValue="#{periodical}"/>
				<f:converter converterId="periodicalConverter" />
			</h:selectOneMenu>
			<h:message for="periodical" label="#{msg.subscription_data_periodical}" />
			<!-- TODO: insert button for editing periodical here -->
			
			<h:outputLabel value="#{msg.subscription_data_status}" for="status" />
			<h:selectOneMenu id="status" value="#{subscriptionBean.currentSubscription.status}">			
				<f:selectItem noSelectionOption="true" itemLabel="#{msg.subscription_data_status_noselection}" />
				<f:selectItems value="#{subscriptionBean.allSubscriptionStates}" var="state" itemLabel="#{state.entryValue}" itemValue="#{state}" />
				<f:converter converterId="predefinedEntryConverter" />
			</h:selectOneMenu>
			<h:message for="status" label="#{msg.subscription_data_status}" />
			
			<h:outputLabel value="#{msg.subscription_data_kindOfAcquisition}" for="kindOfAcquisition" />
			<h:selectOneMenu id="kindOfAcquisition" value="#{subscriptionBean.currentSubscription.kindOfAcquisition}">
				<f:selectItem noSelectionOption="true" itemLabel="#{msg.subscription_data_kindOfAcquisition_noselection}" />
				<f:selectItems value="#{subscriptionBean.allKindsOfAcquisition}" var="kindOfAcquisition" itemLabel="#{kindOfAcquisition.entryValue}" itemValue="#{kindOfAcquisition}" />
				<f:converter converterId="predefinedEntryConverter" />
			</h:selectOneMenu>
			<h:message for="kindOfAcquisition" label="#{msg.subscription_data_kindOfAcquisition}" />
			
			<h:outputLabel value="#{msg.subscription_data_costUnit}" for="costUnit" />
			<h:selectOneMenu id="costUnit" value="#{subscriptionBean.currentSubscription.costUnit}" valueChangeListener="#{subscriptionBean.costUnitChanged}">
				<f:selectItem noSelectionOption="true" itemLabel="#{msg.subscription_data_costUnit_noselection}" />
				<f:selectItems value="#{subscriptionBean.allCostUnits}" var="costUnit" itemLabel="#{costUnit.number} (#{costUnit.name}) #{costUnit.location.city.name}" itemValue="#{costUnit}" />
				<f:converter converterId="costUnitConverter" />
			</h:selectOneMenu>
			<h:message for="costUnit" label="#{msg.subscription_data_costUnit}" />
			
			<h:outputLabel value="#{msg.subscription_data_currentPrice}" for="currentPrice" />
			<h:inputText id="currentPrice" value="#{subscriptionBean.currentSubscription.currentPrice}" size="6" maxlength="10" />
			<h:message for="currentPrice" label="#{msg.subscription_data_currentPrice}" />
			
			<h:outputLabel value="#{msg.subscription_data_currency}" for="currency" />
			<h:selectOneMenu id="currency" value="#{subscriptionBean.currentSubscription.currency}" >
				<f:selectItem noSelectionOption="true" itemLabel="#{msg.subscription_data_currency_noselection}" />
				<f:selectItems value="#{subscriptionBean.allCurrencies}" var="currency" itemLabel="#{currency.entryValue}" itemValue="#{currency}" />
				<f:converter converterId="predefinedEntryConverter" />
			</h:selectOneMenu>
			<h:message for="currency" label="#{msg.subscription_data_currency}" />
			
			<h:outputLabel value="#{msg.subscription_data_paidUntil}" for="paidUntil" onclick="" />
			<h:inputText id="paidUntil" value="#{subscriptionBean.currentSubscription.paidUntil}">
				<f:convertDateTime type="date" pattern="dd.MM.yyyy" locale="#{facesContext.viewRoot.locale}"/>
			</h:inputText>
			<h:message for="paidUntil" label="#{msg.subscription_data_paidUntil}"/>
			
			<h:outputLabel value="#{msg.subscription_data_cancellationPeriod}" for="cancellationPeriod" />
			<h:inputText id="cancellationPeriod" value="#{subscriptionBean.currentSubscription.cancellationPeriod}" />
			<h:message for="cancellationPeriod" label="#{msg.subscription_data_cancellationPeriod}" />
			
			<h:outputLabel value="#{msg.subscription_data_reminderFrequency}" for="reminderFrequency" />
			<h:inputText id="reminderFrequency" value="#{subscriptionBean.currentSubscription.reminderFrequency}" size="3" maxlength="3" />
			<h:message for="reminderFrequency" label="#{msg.subscription_data_reminderFrequency}" />
			
			<h:outputLabel value="#{msg.subscription_data_purchaser}" for="purchaser" />
			<h:selectOneMenu id="purchaser" value="#{subscriptionBean.currentSubscription.purchaser}">
				<f:selectItem noSelectionOption="true" itemLabel="#{msg.subscription_data_purchaser_noselection}" />
				<f:selectItems value="#{subscriptionBean.allPurchasers}" var="purchaser" itemLabel="#{purchaser.firstName} #{purchaser.lastName}" itemValue="#{purchaser}" />
				<f:converter converterId="purchaserConverter" />
			</h:selectOneMenu>
			<h:message for="purchaser" label="#{msg.subscription_data_purchaser}" />
			
			<h:outputLabel value="#{msg.subscription_data_supplier}" for="supplier" />
			<h:selectOneMenu id="supplier" value="#{subscriptionBean.currentSubscription.supplier}">
				<f:selectItem noSelectionOption="true" itemLabel="#{msg.subscription_data_supplier_noselection}" />
				<f:selectItems value="#{subscriptionBean.allSuppliers}" var="supplier" itemLabel="#{supplier.name} (#{supplier.city.name})" itemValue="#{supplier}" />
				<f:converter converterId="supplierConverter" />
			</h:selectOneMenu>
			<h:message for="supplier" label="#{msg.subscription_data_supplier}" />
			
			<h:outputLabel value="#{msg.subscription_data_subscriptionNumber}" for="subscriptionNumber" />
			<h:inputText id="subscriptionNumber" value="#{subscriptionBean.currentSubscription.subscriptionNo}" size="12" maxlength="50" />
			<h:message for="subscriptionNumber" label="#{msg.subscription_data_subscriptionNumber}" />
			
			<h:outputLabel value="#{msg.subscription_data_barcode}" for="barcode" />
			<h:inputText id="barcode" value="#{subscriptionBean.currentSubscription.barcode}" size="20" maxlength="50" />
			<h:message for="barcode" label="#{msg.subscription_data_barcode}" />
			
			<h:outputLabel value="#{msg.subscription_data_signature}" for="signature" />
			<h:inputText id="signature" value="#{subscriptionBean.currentSubscription.signature}" size="12" maxlength="50" />
			<h:message for="signature" label="#{msg.subscription_data_signature}" />
			
			<h:outputLabel value="#{msg.subscription_data_orderingDate}" for="orderingDate" />
			<h:inputText id="orderingDate" value="#{subscriptionBean.currentSubscription.orderingDate}">
				<f:convertDateTime type="date" pattern="dd.MM.yyyy" locale="#{facesContext.viewRoot.locale}"/>
			</h:inputText>
			<h:message for="orderingDate" label="#{msg.subscription_data_orderingDate}" />
		</h:panelGrid>		
	</ui:composition>
</body>
</html>